import greenfoot.*;

/**
 * This class defines a crab. Crabs live on the beach.
 */
public class Crab extends Actor
{
    public void act()
    {
       move(4);
       turnAtEdge();
       control();
       rotate();
    }
    public void turnAtEdge(){
      if(isAtEdge()){
           turn(20);
        }
      }
      public void control(){
     if (Greenfoot.isKeyDown("left")){
         turn(-15);
        }
        if (Greenfoot.isKeyDown("right")){
            turn(15);
        }
        if (Greenfoot.isKeyDown("up")){
            turn(-15);
        }
        if (Greenfoot.isKeyDown("down")){
            turn(15);
        }
    }
    public void rotate(){
        turn(20);
    }
    
}




